<template>
  <div class="list-table">
    <!--    <div class="area-header">-->
    <!--      <span class="area-header-title">{{ $t('基金列表') }}</span>-->
    <!--    </div>-->
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('负责人')" prop="personCharge">
        <UserSelect v-model="queryParams.personCharge" :popper-append-to-body="true" :placeholder="$t('负责人')" />
      </el-form-item>
      <el-form-item :label="$t('基金类型')" prop="fundType">
        <dict-select v-model="queryParams.fundType" dictionary="fund_type" :placeholder="$t('基金类型')" />
      </el-form-item>
      <el-form-item :label="$t('基金状态')" prop="fundStatus">
        <dict-select v-model="queryParams.fundStatus" dictionary="fund_status" :placeholder="$t('基金状态')" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="fundBaseList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金名称')" show-overflow-tooltip align="center" prop="fundName" min-width="110">
        <template slot-scope="scope">
          <a :href="`/fund/fundBasehome?id=${scope.row.id}`" target="_blank" class="link_a">{{ scope.row.fundName }}</a>
        </template>
      </el-table-column>
      <el-table-column :label="$t('基金负责人')" show-overflow-tooltip align="center" prop="personChargeName" min-width="150" />
      <el-table-column :label="$t('基金类型')" show-overflow-tooltip align="center" prop="fundType" min-width="110" :formatter="formatType" />
      <el-table-column :label="$t('基金成立日期')" show-overflow-tooltip align="center" prop="foundationDate" min-width="110" />
      <el-table-column :label="$t('基金状态')" show-overflow-tooltip align="center" prop="fundStatus" min-width="110" :formatter="formatStatus" />
      <el-table-column :label="$t('实缴金额') + $t('金额单位')" align="center" prop="lpPayment" min-width="110">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.lpPayment,'w',2,true) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('认缴金额') + $t('金额单位')" align="center" prop="subAmount" min-width="110">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.subAmount,'w',2,true) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('已投金额') + $t('金额单位')" align="center" prop="dealPayment" min-width="110">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.dealPayment,'w',2,true) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('剩余可投') + $t('金额单位')" align="center" prop="remainAmount" min-width="110">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.remainAmount,'w',2,true) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('TVPI')" align="center" prop="tvpi" min-width="110">
        <template slot-scope="scope">
          <a class="link_a" @click="clickIndicators(scope.row)">{{ moneyFormat(scope.row.tvpi) }}</a>
        </template>
      </el-table-column>
      <el-table-column :label="$t('RVPI')" align="center" prop="rvpi" min-width="110">
        <template slot-scope="scope">
          <a class="link_a" @click="clickIndicators(scope.row)">{{ moneyFormat(scope.row.rvpi) }}</a>
        </template>
      </el-table-column>
      <el-table-column :label="$t('DPI')" align="center" prop="dpi" min-width="110">
        <template slot-scope="scope">
          <a class="link_a" @click="clickIndicators(scope.row)">{{ moneyFormat(scope.row.dpi) }}</a>
        </template>
      </el-table-column>
      <el-table-column :label="$t('Gross IRR')" align="center" prop="irr" min-width="110">
        <template slot-scope="scope">
          <a class="link_a" @click="clickIndicators(scope.row)">{{ moneyFormat(scope.row.irr,'l',2,true) }}</a>
        </template>
      </el-table-column>
      <el-table-column :label="$t('Net IRR')" align="center" prop="netIrr" min-width="110">
        <template slot-scope="scope">
          <a class="link_a" @click="clickIndicators(scope.row)">{{ moneyFormat(scope.row.netIrr,'l',2,true) }}</a>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog :title="title" :visible.sync="formOpen" width="80%" modal-append-to-body :close-on-click-modal="false" custom-class="dialogView" :lock-scroll="false" append-to-body>
      <fund-indicators ref="fundIndicators" />
    </el-dialog>

  </div>
</template>

<script>
import { getFundList } from '@/api/fund/fundBase'
import FundIndicators from '@/views/deal/fundToDealcashflow/fundIndicators.vue'
import { moneyFormat } from '../../../utils/ruoyi'
export default {
  components: {
    FundIndicators
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: '基金列表',
      // 是否显示弹出层
      formOpen: false,
      // 查询参数
      queryParams: {
        personCharge: undefined,
        fundType: undefined,
        fundStatus: undefined,
        pageNum: 1,
        pageSize: 10
      },
      fundBaseList: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      fundTypeOptions: [],
      fundStatusOptions: []
    }
  },
  created() {
    this.initDict()
    this.getList()
  },
  methods: {
    moneyFormat,
    /** 查询入职管理列表 */
    getList() {
      this.loading = true
      getFundList(this.queryParams).then(response => {
        this.fundBaseList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    clickIndicators(row) {
      this.formOpen = true
      this.$nextTick(() => {
        this.$refs.fundIndicators.init({ fundId: row.id })
      })
    },

    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        actId: undefined,
        actStatus: '0',
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined,
        delFlag: undefined,
        actTitle: undefined,
        name: undefined,
        deptId: undefined,
        contractTerm: undefined,
        postId: undefined,
        workAddress: undefined,
        entryTime: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    formatType(row) {
      return this.selectDictLabel(this.fundTypeOptions, row.fundType)
    },
    formatStatus(row) {
      return this.selectDictLabel(this.fundStatusOptions, row.fundStatus)
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.queryHandle()
    },
    initDict() {
      this.getDicts('fund_type').then(response => {
        this.fundTypeOptions = response.data
      })
      this.getDicts('fund_status').then(response => {
        this.fundStatusOptions = response.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
/deep/.customDialog .el-dialog__body {
  height: 32vh;
  overflow-y: auto;
  .list-table {
    margin: -20px;
  }
}
</style>
